<template>
	<view>
		<!-- 修改个人信息界面 -->
		<u-cell-group >
			<u-cell-item  title="头像">
				<image :src="userInfo.avatar_url" mode=""></image>
			</u-cell-item>
			<u-cell-item  title="昵称" :value="userInfo.name" @tap="changeUserName()"></u-cell-item>
			<u-cell-item  title="邮箱" :value="userInfo.email"></u-cell-item>
			<!-- <u-cell-item  title="更换绑定邮箱" :value="userInfo.email"></u-cell-item> -->
			<u-cell-item  title="修改密码" @tap="changePassword()"></u-cell-item>
			<u-cell-item  title="绑定手机号码" @tap="phone()" :value="userInfo.phone ? userInfo.phone:'暂未绑定手机号码'"></u-cell-item>
			<u-cell-item  title="收货地址" @tap="changeAdreess()"></u-cell-item>
		</u-cell-group>


	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo:''
			}
		},
		methods: {
			changePassword(){
				uni.navigateTo({
						url:'/pages/userInfoChange/changePassword'
				})
			},
			changeUserName(){
				uni.navigateTo({
						url:'/pages/userInfoChange/changeInfoUserName'
				})
			},
			changeAdreess(){
				uni.navigateTo({
						url:'/pages/userInfoChange/adreess'
				})
			},
			phone(){
				uni.navigateTo({
						url:'/pages/userInfoChange/changePhone'
				})
			}
		},
	    async onLoad() {
			uni.$on('userInfo',res=>{
				this.userInfo=res;
				// console.log(res)
			})
			uni.$emit('send')
			await this.$u.get('/api/user').then(res=>{
				console.log(res);
				// 获取用户的基本信息
				this.userInfo=res.data
			}).catch(err=>{
				console.log(err)
			})
		}
	}
</script>

<style lang="scss" scoped>
	image{
		width: 79px;
		height:79px;
		border-radius: 79px;
	}
</style>
